package de.fhtrier.gdw2.ships.network.datagrams;

import de.fhtrier.gdw.commons.netcode.datagram.INetDatagram;
import de.fhtrier.gdw.commons.netcode.datagram.INetDatagramFactory;
import de.fhtrier.gdw.commons.netcode.datagram.NetEventDatagram;

public class DatagramFactory implements INetDatagramFactory {

	@Override
	public INetDatagram createDatagram(byte type, short id, short param1, short param2) {
		switch (type) {
			case DatagramType.CONNECT:
				return new ConnectDatagram(type, id, param1, param2);
			case DatagramType.LEVEL:
				return new LevelDatagram(null, type, id, param1, param2);
			case DatagramType.GAMEOVER:
				return new NetEventDatagram(type, id, param1, param2);
			default:
				throw new IllegalArgumentException("type: " + type);
		}
	}
}
